package com.example.mapper;

import com.example.entity.SecondLabel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SecondLabelMapper {

    /**
     * 新建二级标签
     * @param secondLabel
     */
    @Insert("insert into housekeeper.second (type, type_key) values (#{type},#{firstLabelId});")
    void save(SecondLabel secondLabel);

    /**
     * 删除一级标签
     * @param ids
     */
    void del(List<Integer> ids);

    /**
     * 根据一级标签搜索
     * @param id
     * @return
     */
    @Select("select * from housekeeper.second where type_key = #{id};")
    List<SecondLabel> getByTypeKey(int id);

    @Select("select id from housekeeper.second where type = #{type};")
    Long getIdByType(String type);

    @Select("select type from housekeeper.second where id = #{typeKey2};")
    String getNameById(int typeKey2);
}
